#include <stdio.h>
#include <unistd.h>

#include "timercluster.h"

void test_single_callback(timerid_t id, void *userdata)
{
    (void)userdata;
    printf("Timer[%u] triggered: %s\n", id, "test_single");
}

void test_cycle_callback(timerid_t id, void *userdata)
{
    (void)userdata;
    printf("Timer[%u] triggered: %s\n", id, "test_cycle");
}

int main(void)
{
    timercluster_t *cluster = NULL;
    cluster = timercluster_init();
    if (NULL == cluster)
    {
        printf("timercluster_init fail!");
        return -1;
    }

    timercluster_timer_add(cluster, 0, TIMER_TYPE_SINGLE, 2000, test_single_callback, NULL);
    timercluster_timer_add(cluster, 1, TIMER_TYPE_CYCLE, 1000, test_cycle_callback, NULL);

    sleep(5); // 让定时器运行一段时间

    timercluster_timer_del(cluster, 0);
    timercluster_timer_del(cluster, 1);
    timercluster_destroy(cluster);

    return 0;
}
